<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box {
            display: flex;
            justify-content: center;
            align-items: center;
            margin: 20px auto;
            width: 200px;
            height: 100px;
            /* background-color: pink; */
        }
        .operator {
            width: 20px;
            height: 20px;
            text-align: center;
        }
        input {
            width: 50px;
            height: 20px;
        }
        #result {
            width: 50px;
            height: 22px;
            border: 1px solid blue;
            background-color: #fff;
        }
        button {
            display: block;
            margin: 0 auto;
        }
    </style>
</head>
<body>
    <div id="box">
        <input type="text" id="firstNumber" value="">
        <div class="operator">+</div>
        <input type="text" id="secondNumber" value="">
        =
        <div id="result"></div>
    </div>
    <div>
        <button id="add">计算</button>
    </div>
    <script>
        // 获取元素
        var btn = document.getElementById('add');
        // 注册事件 运行程序
        btn.onclick = function() {
            var firstNumber = document.getElementById('firstNumber').value;
            var secondNumber = document.getElementById('secondNumber').value;
            var result = parseInt(firstNumber) + parseInt(secondNumber);
            document.getElementById('result').innerHTML = result;
        }
    </script>
</body>
</html>